Implemented RFC 7239 - "Forwarded HTTP Extension"#94
Implemented RFC 7239 - "Forwarded HTTP Extension"#94dg merged 8 commits intonette:masterfrom patrickkusebauch:master
Conversation
src/Http/RequestFactory.php
Outdated
| $url->setPort((int) $_SERVER['HTTP_X_FORWARDED_PORT']); | ||
| } | ||
| if (isset($proxyParams['for'])) { | ||
| $remoteAddr = explode(':', $proxyParams['for'][0])[0]; |
There was a problem hiding this comment.
This will not work with IPv6.
Will now work with IPv6. Added tests for port and scheme of the URL
- Split test into "x-forwarded" and "forwarded" files for proxy - Added tests for default scheme. - Added tests for every combination of IPv4/IPv6 with and without port for both "host" and "for" headers
|
possible related #92 |
| foreach ($forwardParams as $forwardParam) { | ||
| $param = explode("=", $forwardParam); | ||
| $proxyParams[strtolower(trim($param[0]))][] = trim($param[1], "\"\t\n\r\0\x0B"); //e.g. array['for'][0] = 192.168.0.1 | ||
| } |
There was a problem hiding this comment.
This can be simplified to
foreach ($forwardParams as $forwardParam) {
list($key, $value) = explode('=', $forwardParam, 2) + [1 => NULL];
$proxyParams[strtolower(trim($key))] = trim($value, " \t\"");
}|
I know that it keeps failing on php5.6 with composer update --no-interaction --prefer-dist --prefer-lowest --prefer-stable. However this cannot be redeemed as the tests have to change to keep up with the versions. Furthermore they are test unrelated to this pull request. |
|
Any other problems to be fixed with this PR? |
|
Is it ready for merge? |
|
Since there were no comments to the PR for more than 3 weeks, I would assume nobody has any more problems with it. |
|
So thanks! |
|
I thank you for letting me be a part of the development of Nette. :) |
* Implemented RFC 7239 - " Forwarded HTTP Extension" handling in RequestFactory * Implemented RFC 7239 - " Forwarded HTTP Extension" handling in RequestFactory * Deleted echo statement * case- insensitive handling of tokens * Proper handle of quoted strings. Will now work with IPv6. Added tests for port and scheme of the URL [Closes #94] * Tests refactoring: - Split test into "x-forwarded" and "forwarded" files for proxy - Added tests for default scheme. - Added tests for every combination of IPv4/IPv6 with and without port for both "host" and "for" headers * Code simplifications * Fixed coding standards for tests
RequestFactory can now take "RemoteAddress", "RemoteHost", "port" and "scheme" from the proxy "FORWARDED" header.